package com.atguigu.gmall.common.pool;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class RunTreadPool {
//线程池
    @Bean
    public ThreadPoolExecutor threadPoolExecutor(){
      return   new ThreadPoolExecutor(
                5,
                10,
                10,
                TimeUnit.SECONDS,
                //阻塞队列
                new ArrayBlockingQueue<>(10)
        );
    }

    //  @Bean
    //    public ThreadPoolExecutor threadPoolExecutor(){
    //        //1:办法
    //        //Executors.newCachedThreadPool()  强制禁止使用
    //        //2:创建线程池
    //        return new
    //                ThreadPoolExecutor(
    //                        5,//核心线程
    //                       10,//最大线程
    //                       10,//存活时间
    //                       TimeUnit.SECONDS,
    //                       new ArrayBlockingQueue(10)
    //
    //        );
}
